<template>
  <!-- 列表区域 -->
  <section class="main">
    <ul class="todo-list">
      <li v-for="(v, i) of list" :key="v.id" class="todo">
        <div class="view">
          <span class="index">{{ i + 1 }}.</span> <label>{{ v.name }}</label>
          <button class="destroy" @click="del(v.id)"></button>
        </div>
      </li>
    </ul>
  </section>
</template>

<script>
export default {
  name: 'TodoMain',
  props: {
    list: {
      type: Array, // 类型限定
      required: true, // 必传
    }
  },
  methods: {
    del(id) {
      // 通知父组件，我要删除这个任务
      this.$emit('del', id)
    }
  }
}
</script>

<style>

</style>